//登录
const Service = require('./base_service')

class LoginService extends Service {
  login (userInfo) {
    let { userName, passWord } = userInfo
    let queryString = `
      SELECT name,password FROM sys_admin_user where name=$1 and password=$2
    `
    return new Promise((resolve, reject) => {
      this.postgreServer()
        .connect()
        .then(client => {
          client.query(queryString, [userName, passWord], (err, res) => {
            client.release()
            if (err) {
              return reject(err)
            }
            resolve(res)
          })
        })
        .catch(err => {
          console.log(err)
        })
    })
  }
}

module.exports = LoginService